package com.haimi.shiguang.business.user.login;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.haimi.shiguang.R;
import com.haimi.shiguang.base.BaseActivity;
import com.haimi.shiguang.base.FragmentController;
import com.haimi.shiguang.business.user.register.RegisterFragment;
import com.haimi.shiguang.utils.ButtonClickTimer;

/**
 * @author changsunhaipeng
 * @date 2018/6/16
 */

public class LoginActivity extends BaseActivity {

    private TextView mLogin;
    private TextView mRegister;
    private ImageView mClose;
    private TextView mLoginWeiXIn;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public int setLayout() {
        return R.layout.activity_login;
    }

    @Override
    public void initView() {
        mLogin = findViewById(R.id.tv_title_login);
        mLogin.setSelected(true);
        mRegister = findViewById(R.id.tv_title_register);
        mClose = findViewById(R.id.iv_close);
        mLoginWeiXIn = findViewById(R.id.iv_login_weixin);
        mClose.setOnClickListener(this);
        mLoginWeiXIn.setOnClickListener(this);
        mLogin.setOnClickListener(this);
        mRegister.setOnClickListener(this);
    }

    @Override
    public void initData() {

    }

    @Override
    public void initListener() {

    }

    @Override
    public void onClick(View v) {
        if (!ButtonClickTimer.canClick(v)) {
            return;
        }
        switch (v.getId()) {
            case R.id.tv_title_login:
                mLogin.setSelected(true);
                mRegister.setSelected(false);
                FragmentController.addFragment(getSupportFragmentManager(), LoginFragment.newInstance(), LoginFragment.TAG);
                break;
            case R.id.tv_title_register:
                mLogin.setSelected(false);
                mRegister.setSelected(true);
                FragmentController.addFragment(getSupportFragmentManager(), RegisterFragment.newInstance(), RegisterFragment.TAG);
                break;
            case R.id.iv_close:
                finishCurrent();
                break;
            case R.id.iv_login_weixin:
                break;
            default:
                break;
        }
    }
}
